package com.learn.design.strategy.example;

import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * @author Administrator
 */
@Component
public class FormHsfSubmitHandler implements FormSubmitHandler<Serializable> {


    @Override
    public String getSubmitType() {
        return "hsf";
    }

    @Override
    public CommonPairResponse<String, Serializable> handleSubmit(FormSubmitRequest request) {
        System.out.printf("HSF 模式提交：userId=%s, formInput=%s%n", request.getUserId(), request.getFormInput());

        // 进行 HSF 泛化调用，获得业务方返回的提示信息和业务数据
        CommonPairResponse<String, Serializable> response = hsfSubmitData(request);

        return response;
    }

    private CommonPairResponse<String, Serializable> hsfSubmitData(FormSubmitRequest request) {
        return CommonPairResponse.success("hsf", 111);
    }

}
